package com.grape.dbmiddle.consumer.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 * 描述:交换机绑定队列
 * @author: myx
 * @date: 2019-05-01
 * Copyright © 2019-grape. All rights reserved.
 */
@Component
public class FanoutConfig {

	// 1.定义队列
	@Bean
	public Queue fanOutTxQueue() {
		return new Queue("tx-quene-from");
	}


	// 2.定义交换机
	@Bean
	FanoutExchange fanoutExchange() {
		return new FanoutExchange("tx");
	}

	// 3.队列与交换机绑定邮件队列
	@Bean
	Binding bindingExchangeEamil(Queue fanOutTxQueue, FanoutExchange fanoutExchange) {
		return BindingBuilder.bind(fanOutTxQueue).to(fanoutExchange);
	}
}